package edu.njfu.intentdemo2

import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_third.*

class ThirdActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_third)
        button3.setOnClickListener {
            var name = intent.getStringExtra("name")
            var password=intent.getStringExtra("password")
            var msg=""
            if(name.equals("zhangsan") && password.equals("123456")){
                msg="用户名与密码正确"
            }else{
                msg="用户名与密码错误！"
            }
            val intent2= Intent()
            intent2.putExtra("msg",msg)
            //设置Result
            setResult(Activity.RESULT_OK,intent2)
            //关闭自己
            finish()
        }
    }
}